<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
 <%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
    <title></title>
    <link href="themes/css/ui.common.css" rel="stylesheet" type="text/css" />
    <link href="themes/css/ui.child.css" rel="stylesheet" type="text/css" />
    <link href="themes/css/ui.tips.css" rel="stylesheet" type="text/css" />
    <link href="style/jquery_ui/jquery-ui-1.8.custom.css" rel="stylesheet" type="text/css" />
    <link id="skin_css" type="text/css" rel="stylesheet" href="themes/css/ui.c.blue.css" />
    <link rel="stylesheet" type="text/css" href="themes/default/pagination.css" />
    <link href="themes/css/ui.selector.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery-ui-1.8.custom.min.js" type="text/javascript"></script>
    <script src="Scripts/jquery.json-2.2.min.js" type="text/javascript"></script>
    <script src="Scripts/ui.tips.js" type="text/javascript"></script>
    <script src="Scripts/ui.default.js " type="text/javascript" charset="UTF-8"></script>
    <script src="Scripts/ui.admincp.js" type="text/javascript" charset="UTF-8"></script>
    <script src="Scripts/ui.objectSelector.js" type="text/javascript"></script>
    <script src="HtmlEditor/kindeditor.js" type="text/javascript"></script>
    <script src="Scripts/HtmEditorCreator.js" type="text/javascript"></script>
    <script type="text/javascript" src="Scripts/ui.clientDateHelper.js"></script>
    <script type="text/javascript">
        $(function () { 
            $("#btn_Add").click(function () {
                addNews();
            });
            
            var times = loadTime();
            var now= new Date();  
   			
   			var defaultDate = getCurrentDateTime("-");
   			 
			$("#txt_StartTime").html(times);
			$("#txt_EndTime").html(times);
			$("#txt_StartDate").val(defaultDate);
			$("#txt_EndDate").val(defaultDate);
        });

 
		
		
        $(function () {
            $("#sectionSelectorForm,#peopleSelectorForm").dialog("destroy");
            $("#sectionSelectorForm,#peopleSelectorForm").dialog({
                autoOpen: false,
                height: 460,
                width: 690,
                modal: true,
                close: function () {
                    //allFields.val('').removeClass('ui-state-error');
                }
            });

            $("#btnShowSectionSelector,#btnShowPeopleSelector").click(function () {
                var formId = $(this).attr("formid");
                closeDialogForm("#" + formId, 'open');
            });

            CreateEditor("txt_Content", "");

            initializePeopleSelector();
            initializeSectionSelector();
        });

        function closeDialogForm(formSelector, action) { $(formSelector).dialog(action); }


        function initializeSectionSelector() {
            $("#sectionSelectorArea").objectSelector({
                 
            });   
        }
        
         function subGroupBuilder(item) {
       	 
            var sectionId = item.archiveInfo.postInfo.sectionInfo.sectionId;
            var name = item.archiveInfo.staffName;
            var staffId = item.staffId;
            var info = item.archiveInfo.gender;
            var groupId = sectionId;
            return '<div class="groupItem"><a class="lm_addr" key="g' + sectionId + '" href="javascript:void(0)"><input type="button" class="move" />'
            + '<div class="arguementBar" key="g' + sectionId  + '" entityId="' + staffId + '" itemindex="0" title="">'
            + name + ' <span class="details Tips3">' + info + '</span></div></a></div>';
        }

        function initializePeopleSelector() {
            $("#peopleSelectorArea").objectSelector({
                fromAjax: true,
                ajaxDataAction: "move!getPersonBySectionId.action",
                 subGroupBuilder: subGroupBuilder,
                postArgBuilder :function(entityId){ return {sectionId: entityId};}
            }); 
        }

        function getAllSelectedSections() {
            $.fn.objectSelector.pushSelectionsTo("#sectionSelectorArea", "#txt_SectionReceiver");
            closeDialogForm("#sectionSelectorForm", 'close');
        }

        function getAllSelectedPeople() {
            $.fn.objectSelector.pushSelectionsTo("#peopleSelectorArea", "#txt_PeopleReceiver");
            closeDialogForm("#peopleSelectorForm", 'close');
        }

        function addNews() {
            var objectsForPeople = $.fn.objectSelector.getSelectorResultFrom("#txt_PeopleReceiver");
            var objectsSection = $.fn.objectSelector.getSelectorResultFrom("#txt_SectionReceiver");

            var idsForPeople = foreachHandler(objectsForPeople, function (item) { return item.value + ","; })
            var idsForSection = foreachHandler(objectsSection, function (item) { return item.value + ","; });
		 
			var title = $("#txt_Title").val();
			var place = $("#txt_Place").val();
			var content = $("#txt_Content").val();
			var postScript = $("#txt_PostScript").val();
			var startTime = $("#txt_StartDate").val()+" "+$("#txt_StartTime").val();
			var endTime = $("#txt_EndDate").val()+" "+$("#txt_EndTime").val();
			
             var dateAvaliable = validateDateTime(startTime,endTime);
              
             if(dateAvaliable==false){return false;}
	           location.href = "notice!add.action?title="+title+ "&place="+place+"&staffIds="+idsForPeople+"&sectionIds="+idsForSection+"&content="+content+"&postScript="+postScript+"&startTime="+startTime+"&endTime="+endTime;
        }
    </script>
</head>
<body>
		 <div class="PageChild_Title">
        <img src=" themes/images/default/icons/archives.png" class="PageChild_Tbtnpic" />
        <span class="PageChild_separate"></span><span class="PageChild_TbtnText">
        <h2>
       		创建会议通知
        </h2>
        </span><span class="PageChild_separate"></span>
        <div id="marker" class="red-tips">
        </div>
        <div class="clear">
        </div>
    </div>
    <div>
    <form action="notice!add.action">
       <table width="99%" style="height: 250px;" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td class="mtd" style="width: 79px;">
                    标题:
                </td>
                <td>
                    <input type="text" class="control" id="txt_Title" maxlength="500" style="width: 100%" name="noticeInfo.title" />
                </td>
            </tr>
			<tr>
                <td class="mtd" style="width: 79px;">
                    地点:
                </td>
                <td>
                    <input type="text" class="control" id="txt_Place" maxlength="500" style="width: 100%" name="noticeInfo.place" />
                </td>
            </tr>
            <tr>
                <td class="mtd" valign="top">
                    <a href="javascript:void(0);" id="btnShowPeopleSelector" formid="peopleSelectorForm"
                        title="单击选择人员">发送到人员:</a>
                </td>
                <td valign="top" align="left">
                    <div class="text-container" style="margin: 0;">
                        <ul class="text-container-inner objectSelector-result" id="txt_PeopleReceiver" >
                        </ul>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="mtd" valign="top">
                    <a href="javascript:void(0);" id="btnShowSectionSelector" formid="sectionSelectorForm"
                        title="单击选择部门">发送到部门: </a>
                </td>
                <td valign="top">
                    <div class="text-container">
                        <ul class="text-container-inner  objectSelector-result" id="txt_SectionReceiver">
                        </ul>
                    </div>
                </td>
            </tr>
            <tr>
                <td class="mtd" valign="top">
                    时间:
                </td>
                <td>
                    <table border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td class="mtd">
                                起始:
                            </td>
                            <td>
                                <input type="text" id="txt_StartDate" class="NeedDate" value=" " />
                            </td>
                            <td>
                                <select id="txt_StartTime">
                                    <option value="1">3:00~3:50</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="mtd">
                                结束:
                            </td>
                            <td>
                                <input type="text" id="txt_EndDate" class="NeedDate" value=" "/>
                            </td>
                            <td>
                                <select id="txt_EndTime"  >
                                    <option value="1">3:00~3:50</option>
                                </select>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td class="mtd" style="width: 79px;">
       	备注:
                </td>
                <td>
                    <input type="text" class="control" id="txt_PostScript" maxlength="500" style="width: 100%" />
                </td>
            </tr>
            <tr>
                <td class="mtd" valign="top">
                    内容:
                </td>
                <td align="top">
                    <input type="text" id="txt_Content" mode="Full" class="control ui-text-editor"  style="width: 100%;
                        height: 300px;" />
                </td>
            </tr>
						<tr>
							<td>
								&nbsp;
							</td>
							<td>
								   <button id="btn_Add" class="o-btn SubmitButton" onclick="return false; ">
                发布</button>&nbsp;&nbsp;	
							</td>
							<td>
								&nbsp;
							</td>
						</tr>
        </table> 
      </form>
    </div>
    <div id="peopleSelectorForm" class="hiddenObject" title="选择要发送到的人员">
        <div id="peopleSelectorArea" selectorresult="#txt_PeopleReceiver" style="">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td valign="top">
                        <span>选择人员:</span>
                        <div class="Box leftContainer" style="overflow-y: auto; height: 362px;">
                            <div class="lm_sbar hiddenObject">
                                <input type="button" class="lm_sopen" style="" />
                                <div>
                                    <input type="text" style="height: 19px;" value="查找人员..." class="txt" />
                                </div>
                            </div>
                            <div style="display: none">
                                查找到以下结果:
                                <div>
                                </div>
                            </div>
                            <div class="lm_panel hiddenObject" style="">
                            </div>
                            <div class="lm_panel" style="height: 100%;">
                                <s:iterator value="sectionList" var="item"> 
                                        <div class="groupclose" key="g${item.sectionId }" entityId="${item.sectionId }" open="false" hasload="false" style="font-weight: bolder;">
                                        <div style="padding: 2px 0pt 1px; background: none repeat scroll 0% 0% rgb(255, 255, 255);
                                            color: black;" onmouseout="this.style.background='#fff'" onmouseover="this.style.background='#ffeec2'"
                                            class="">
                                            <div class="clear"></div>
                                            <span class="Tips3 lm_helper">全部添加</span>
                                            <div class="lm_ca" title="${item.sectionName}">
                                                <input type="button" class="lm_ico" />
                                                ${item.sectionName} <span class="Tips3 groupItemCountTips"  id="groupTips_${item.sectionId }">(未加载)</span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="groupsub" key="g${item.sectionId }">
                                    </div>
                                </s:iterator>
                                
                            </div>
                        </div>
                    </td>
                    <td align="center" style="padding: 5px;">
                        <img alt="" src="style/arrow_left.gif" />
                    </td>
                    <td valign="top">
                        <span>已选择(<span id="count_Receiver" class="receiverCounter">0</span>)</span>
                        <div id="add_address" style="overflow-y: auto; height: 362px; padding-left: 3px;"
                            class="Box objectSelectorContainer rightContainer">
                        </div>
                    </td>
                </tr>
            </table>
            <div>
                <input type="button" name="name" id="btnCloseSelector" onclick="return getAllSelectedPeople();"
                    value="确定" title="提交选择,返回正文界面" />
                <input type="button" id="btnCloseSelectBar" class="dialogFormCloseButton" dialogform="#peopleSelectorForm"
                    value="取消" title="返回正文界面" />
            </div>
        </div>
    </div>
    <div id="sectionSelectorForm" class="hiddenObject" title="选择要发送到的部门">
        <div id="sectionSelectorArea" selectorresult="#txt_SectionReceiver">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td valign="top">
                        <span>选择部门:</span>
                        <div class="Box leftContainer" style="overflow-y: auto; height: 320px; width: ">
                            <div class="lm_sbar hiddenObject">
                                <input type="button" class="lm_sopen" style="" id="btn_UserSearch" />
                                <div>
                                    <input type="text" id="txt_SearchText" style="height: 19px;" value="查找人员..." class="txt" />
                                </div>
                            </div>
                            <div id="lb_SearchTips" style="display: none">
                                查找到以下结果:
                                <div id="lm_ifNullTips">
                                </div>
                            </div>
                            <div class="lm_panel hiddenObject" style="">
                            </div>
                            <div class="lm_panel">
                                <div class="groupclose" key="g1" entityid="1" open="false" hasload="true" style="font-weight: bolder;">
                                    <div style="padding: 2px 0pt 1px; background: none repeat scroll 0% 0% rgb(255, 255, 255);
                                        color: black;" onmouseout="this.style.background='#fff'" onmouseover="this.style.background='#ffeec2'"
                                        class="">   <div class="clear"></div>
                                        <span class="Tips3 lm_helper">全部添加</span>
                                        <div class="lm_ca" title="部门列表">
                                            <input type="button" class="lm_ico" />
                                            部门列表<span class="Tips3 groupItemCountTips">(未加载)</span>
                                        </div>
                                    </div>
                                </div>
                                <div id="groupOne" class="groupsub" key="g1">
                                    <s:iterator value="sectionList" var="item"> 
                                                <div class="groupItem"><a class="lm_addr" key="g1" href="javascript:void(0)">
                                <div class="arguementBar" key="g1" entityId="${item.sectionId }" itemindex="0" title="${item.sectionName}">
                           ${item.sectionName}  <span class="details Tips3"> </span></div></a></div>
                            </s:iterator>
                                </div>
                            </div>
                        </div>
                    </td>
                    <td align="center" style="padding: 5px;">
                        <img alt="" src="style/arrow_left.gif" />
                    </td>
                    <td valign="top">
                        <span>已选择(<span id="Span1" class="receiverCounter">0</span>)</span>
                        <div id="sectionReceiver" style="overflow-y: auto; height: 320px; padding-left: 3px;"
                            class="Box objectSelectorContainer rightContainer">
                        </div>
                    </td>
                </tr>
            </table>
            <div>
                <input type="button" name="name" id="btnGetAllSection" onclick="return getAllSelectedSections();"
                    value="确定" title="提交选择,返回正文界面" />
                <input type="button" class="dialogFormCloseButton" dialogform="#sectionSelectorForm"
                    value="取消" title="返回正文界面" />
            </div>
        </div>
    </div>
</body>
</html>
